package com.example.demo.controller;

import com.example.demo.entity.bean.dataSource1.MemberBean;
import com.example.demo.entity.bean.dataSource1.StoryBean;
import com.example.demo.entity.dataSource1.MemberEntity;
import com.example.demo.service.dataSource1.impl.StoryService;
import com.fasterxml.jackson.annotation.JsonView;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * Created by Wen Gao on 2018/7/25.
 */
@Api(value="新闻稿controller",tags={"新闻稿操作接口"})
@RestController
@RequestMapping("/story")
public class StoryController {

    private static final Logger logger = LogManager.getLogger(StoryController.class);

    @Autowired
    StoryService storyService;

    @ApiOperation(value = "根据storyId获取storyBean", response = StoryBean.class)
    @ApiImplicitParam(name = "storyId", value = "新闻稿id", required = true, dataType = "int")
    @RequestMapping(value = "/{storyId}", method = RequestMethod.GET)
    public StoryBean getStoryBean(@PathVariable(name = "storyId") int storyId) {
        StoryBean simpleStoryBean = storyService.getSimpleStoryBean(storyId);
        return simpleStoryBean;
    }

    @ApiOperation(value = "全量更新一个新闻稿", response = StoryBean.class)
    @ApiParam(name = "全量storyBean", required = true)
    @RequestMapping(value = "/", method = RequestMethod.PATCH)
    public StoryBean updateStoryBean(StoryBean storyBean) {
//        return storyService.updateStoryBean(storyBean);
        return storyBean;
    }
}
